#include "MyPlugin.h"

MyPlugin::MyPlugin(QLibrary* dylibrary)
    : AppFrame::FITKAbstractPlugin(dylibrary)
{
}

QString MyPlugin::getPluginName()
{
    return "MyPlugin";
}

void MyPlugin::install()
{
    // 1. 初始化资源
    Q_INIT_RESOURCE(myplugin_resources);
    
    // 2. 创建UI元素
    auto action = new QAction(tr("My Plugin"), this);
    action->setIcon(QIcon(":/icons/myplugin.png"));
    
    // 3. 添加到主界面
    auto mainWindow = FITKAPP->getMainWindow();
    mainWindow->addAction(action);
    
    // 4. 连接信号槽
    connect(action, &QAction::triggered, this, &MyPlugin::exec);
}

void MyPlugin::unInstall()
{
    // 清理资源
    Q_CLEANUP_RESOURCE(myplugin_resources);
}

bool MyPlugin::exec()
{
    // 实现插件主要功能
    return true;
} 